<template>
    <div>
        <van-nav-bar title="积分支付" left-text="返回" left-arrow @click-left="onClickLeft" />
        
    <!-- 密码输入框 -->
        <el-input placeholder="请输入6位数密码" v-model="password" show-password style="width: 100%; height: 30%;"></el-input>
    
        <div style="position: fixed; right: 20px; bottom: 20px;">
            <el-button type="danger" @click="pay()" round>支付</el-button>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            password: '',
            showKeyboard: true,
            goodId: '',
            totalMoney: '',
            orderId:''
        }
    },
    methods: {
        onClickLeft() {
            this.$router.push({ name: "orderInfo", params: { id: this.goodId } });
        },
        pay() { 
            this.$axios.post('http://localhost:7000/shop/pay', { userPassword: this.password, goodId: this.goodId, orderId:this.orderId }).then(res => {
                if (res.data.code == 1) {
                    alert("支付成功,您的取件码为"+res.data.data+"请在三日之内去后勤部领取奖品!")
                    this.$router.push({ name: "order", params: { code:res.data.data } });
                } else {
                    alert("密码错误,请重新输入!")
                   this.password=''
                }
            });
        }
        
        
    },
    //生命周期 - 创建完成（访问当前this实例）
    created() {
        
    },
    //生命周期 - 挂载完成（访问DOM元素）
    mounted() {
        this.goodId = this.$route.params.id;
        this.totalMoney = this.$route.params.totalMoney;
        this.orderId = this.$route.params.orderId;
    }
}
</script>
<style scoped>
/* @import url(); 引入css类 */

</style>